//package com.tdcoding.chat.dbase;
//
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//
//import com.tdcoding.chat.entities.GroupInfo;
//import com.tdcoding.chat.entities.MemberInfo;
//import com.tdcoding.chat.entities.RegionInfo;
//import com.tdcoding.chat.entities.RequestInfo;
//import com.tdcoding.chat.helper.Logger;
//import com.tdcoding.chat.helper.StringHelper;
//import com.tdcoding.chat.manager.DBManager;
//
///**
// * 群管理
// * 
// * @author Wellsa
// *
// */
//public class DBForGroup {
//	private static final String TAG = "DBForGroup";
//	private static final String GROUP_TABLE = "ofGroup";
//	private static final String MEMBER_TABLE = "ofMember";
//	private static final String MESSAGE_TABLE = "ofMessage";
//
//	/**
//	 * 创建群
//	 * 
//	 * @return
//	 */
//	static final String CREATE_GROUP = "groupId,groupName,groupLogo,belongId,belongName,groupLevel,"
//			+ "groupType,groupIntro,groupNotice,allowedJoin,isSilence,creationDate";
//
//	public static int createGroup(long userId,String userHead, GroupInfo groupInfo) {
//		long groupId = StringHelper.getUniqueId(1);
//		String values = groupId + ",'" + groupInfo.getGroupName() + "','" + groupInfo.getGroupLogo() + "'," + userId
//				+ ",'" + groupInfo.getNickName() + "'," + 0 + "," + 0 + ",'" + groupInfo.getGroupIntro() + "','',"
//				+ groupInfo.getAllowedJoin() + "," + 1 + "," + new Date().getTime();
//		int result = DBManager.insertSql(0, GROUP_TABLE, CREATE_GROUP, values);
//		if (result != -1) {
//			MemberInfo memberInfo=new MemberInfo();
//			memberInfo.setGroupId(groupId);
//			memberInfo.setMemberHead(userHead);
//			memberInfo.setMemberName(groupInfo.getUserName());
//			memberInfo.setMemberNick(groupInfo.getNickName());
//			result = joinToGroup(userId, memberInfo, true);
//			if (result == -1) {
//				DBManager.deleteSql(0, GROUP_TABLE, "groupId=" + groupId);
//			}
//		}
//		return result;
//	}
//
//	/**
//	 * 创建群
//	 * 
//	 * @return
//	 */
//	static final String CREATE_GISGROUP = "groupId,groupName,belongId,belongName,groupLevel,"
//			+ "groupType,groupIntro,isMember,creationDate";
//
//	public static int createDisgroup(RequestInfo requestInfo) {
//		long groupId = StringHelper.getUniqueId(2);
//		Object[] parameters=requestInfo.getParameters();
//		GroupInfo groupInfo=(GroupInfo) parameters[0];
//		String values = groupId + ",'" +groupInfo.getGroupName() + "'," + requestInfo.getUserId() + ",'"
//				+ groupInfo.getNickName()+ "',0,1" + ",'" +" ''" + "',1,"
//				+ new Date().getTime();
//		int result = DBManager.insertSql(0, GROUP_TABLE, CREATE_GISGROUP, values);
//		if (result != -1) {
//			MemberInfo memberInfo=new MemberInfo();
//			memberInfo.setGroupId(groupId);
//			memberInfo.setMemberHead(requestInfo.getUserHead());
//			memberInfo.setMemberName(requestInfo.getUserName());
//			memberInfo.setNickName(requestInfo.getNickName());
//			memberInfo.setMemberNick(requestInfo.getNickName());
//			result = joinToGroup(requestInfo.getUserId(),memberInfo, true);
//			if (result == -1) {
//				return result;
//			}
//			List<MemberInfo> memberInfos = groupInfo.getMemberInfos();
//			for (MemberInfo memberInfo1 : memberInfos) {
//				result = joinToGroup(requestInfo.getUserId(), memberInfo1, true);
//			}
//
//		}
//		return result;
//	}
//
//	/**
//	 * 查询群信息
//	 * 
//	 * @param groupId
//	 * @return
//	 */
//	public static GroupInfo queryGroupInfo(long userId, long groupId) {
//		String where = " where ofg.groupId=" + groupId;
//		String sql = "SELECT ofg.*,"
//				+ "(SELECT nickName from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as nickName,"
//				+ "(SELECT isMember from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as isMember,"
//				+ "(SELECT isSilence from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as isMSilence,"
//				+ "(SELECT identity from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as identity,"
//				+ "(SELECT COUNT(*) from ofmember ofm where ofg.groupId=ofm.groupId  and isMember=1) as memberCount"
//				+ " FROM ofgroup ofg" + where;
//		try {
//			ResultSet resultSet = DBManager.querySql(0, sql);
//			if (resultSet.first()) {
//				GroupInfo groupInfo = new GroupInfo();
//				groupInfo.setIdentity(resultSet.getInt("identity"));
//				groupInfo.setIsSilence(resultSet.getInt("isSilence"));
//				groupInfo.setIsMSilence(resultSet.getInt("isMSilence"));
//				groupInfo.setIsMember(resultSet.getInt("isMember"));
//				groupInfo.setGroupId(resultSet.getLong("groupId"));
//				groupInfo.setBelongId(resultSet.getLong("belongId"));
//				groupInfo.setAllowedJoin(resultSet.getInt("allowedJoin"));
//				groupInfo.setBelongName(resultSet.getString("belongName"));
//				groupInfo.setGroupType(resultSet.getInt("groupType"));
//				groupInfo.setGroupLevel(resultSet.getInt("groupLevel"));
//				groupInfo.setNickName(resultSet.getString("nickName") );
//				groupInfo.setGroupName(resultSet.getString("groupName"));
//				groupInfo.setGroupLogo(resultSet.getString("groupLogo") );
//				groupInfo.setCreateDate(resultSet.getLong("creationDate"));
//				groupInfo.setMemberCount(resultSet.getInt("memberCount"));
//				groupInfo.setModifiedDate(resultSet.getLong("modifiedDate"));
//				RegionInfo regionInfo = DBForRegion.queryRegionInfo(groupId, 1);
//				if (regionInfo != null) {
//					groupInfo.setRegionInfo(regionInfo);
//				}
//				List<MemberInfo> lMemberInfos = queryMembers(groupId, 5);
//				groupInfo.setMemberInfos(lMemberInfos);
//				return groupInfo;
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return null;
//	}
//
//	/**
//	 * 查询群成员信息
//	 * 
//	 * @param groupId
//	 * @return
//	 */
//	public static MemberInfo queryMemberInfo(long userId, long groupId, long memberId) {
//		Object[] objs = new Object[2];
//		String where = " where ofm.memberId=" + memberId;
//		String sql = "SELECT ofm.*," + "(SELECT isFriend from offriend off where off.userId=" + userId
//				+ " and off.friendId=" + memberId + ") as isFriend,"
//				+ "(SELECT identity from ofgroup ofg where ofg.groupId=" + groupId + " and ofg.memberId=" + userId
//				+ ") as myIdentity," + " FROM ofMember ofm" + where;
//		try {
//			MemberInfo memberInfo=new MemberInfo();
//			ResultSet resultSet = DBManager.querySql(0, sql);
//			if (resultSet.first()) {
//				objs[0] = resultSet.getInt("myIdentity");
//				memberInfo.setIdentity(resultSet.getInt("identity"));
//				memberInfo.setIsFriend(resultSet.getInt("isFriend"));
//				memberInfo.setIsSilence(resultSet.getInt("isSilence"));
//				memberInfo.setGroupId(resultSet.getLong("groupId"));
//				memberInfo.setMemberId(resultSet.getLong("memberId"));
//				memberInfo.setNickName(resultSet.getString("nickName"));
//				memberInfo.setMemberHead(resultSet.getString("memberHead"));
//				memberInfo.setMemberName(resultSet.getString("memberName"));
//				memberInfo.setMemberHonor(resultSet.getString("memberHonor"));
//			}
//			return memberInfo;
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return null;
//	}
//
//	/**
//	 * 查询群列表
//	 * 
//	 * @param keyword
//	 * @param pageIndex
//	 * @param pageCount
//	 * @return
//	 */
//	public static List<GroupInfo> searchGroupList(long userId, String keyword, int groupType, int pageIndex,
//			int pageCount) {
//		String where = " where groupType=" + groupType + " and ofg.groupName LIKE '%" + keyword + "%'";
//		String limit = "";
//		if (pageIndex != 0 && pageCount != 0) {
//			int start = pageCount * (pageIndex - 1);
//			int end = start + pageCount - 1;
//			limit = " limit " + start + "," + end;
//		}
//		String orderBy = " order by modifiedDate desc";
//		String sql = "SELECT ofg.*,"
//				+ "(SELECT nickName from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as nickName,"
//				+ "(SELECT isMember from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as isMember,"
//				+ "(SELECT isSilence from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as isMSilence,"
//				+ "(SELECT identity from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as identity,"
//				+ "(SELECT COUNT(*) from ofmember ofm where ofg.groupId=ofm.groupId and isMember=1) as memberCount"
//				+ " FROM ofgroup ofg" + where + orderBy + limit;
//		List<GroupInfo> groupInfos=new ArrayList<GroupInfo>();
//		try {
//			ResultSet resultSet = DBManager.querySql(0, sql);
//			while (resultSet.next()) {
//				GroupInfo groupInfo = new GroupInfo();
//				long groupId = resultSet.getLong("groupId");
//				groupInfo.setGroupId(groupId);
//				groupInfo.setIdentity(resultSet.getInt("identity"));
//				groupInfo.setIsSilence(resultSet.getInt("isSilence"));
//				groupInfo.setIsMSilence(resultSet.getInt("isMSilence"));
//				groupInfo.setIsMember(resultSet.getInt("isMember"));
//				groupInfo.setBelongId(resultSet.getLong("belongId"));
//				groupInfo.setAllowedJoin(resultSet.getInt("allowedJoin"));
//				groupInfo.setBelongName(resultSet.getString("belongName") );
//				groupInfo.setGroupType(resultSet.getInt("groupType"));
//				groupInfo.setGroupLevel(resultSet.getInt("groupLevel"));
//				groupInfo.setNickName(resultSet.getString("nickName") );
//				groupInfo.setGroupName(resultSet.getString("groupName") );
//				groupInfo.setGroupLogo(resultSet.getString("groupLogo"));
//				groupInfo.setMemberCount(resultSet.getInt("memberCount"));
//				groupInfo.setGroupIntro(resultSet.getString("groupIntro") );
//				groupInfo.setCreateDate(resultSet.getLong("creationDate"));
//				RegionInfo regionInfo = DBForRegion.queryRegionInfo(groupId, 1);
//				if (regionInfo != null) {
//					groupInfo.setRegionInfo(regionInfo);
//				}
//				List<MemberInfo> lMemberInfos = queryMembers(groupId, 5);
//				groupInfo.setMemberInfos(lMemberInfos);
//				groupInfos.add(groupInfo);
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return groupInfos;
//	}
//
//	/**
//	 * 查询群成员
//	 * 
//	 * @param groupId
//	 * @param pageIndex
//	 * @param pageCount
//	 * @return
//	 */
//	public static List<MemberInfo> queryGroupMember(long groupId, int pageIndex, int pageCount) {
//		String where = "groupId=" + groupId;
//		String orderBy = "joinDate desc";
//		String limit = "";
//		if (pageIndex != 0 && pageCount != 0) {
//			int start = pageCount * (pageIndex - 1);
//			int end = start + pageCount - 1;
//			limit = " limit " + start + "," + end;
//		}
//		List<MemberInfo> memberInfos=new ArrayList<MemberInfo>();
//		try {
//			ResultSet resultSet = DBManager.querySql(0, MEMBER_TABLE, null, where, orderBy, null, limit);
//			while (resultSet.next()) {
//				int isMember = resultSet.getInt("isMember");
//				if (isMember != 1) {
//					continue;
//				}
//				MemberInfo memberInfo =new MemberInfo();
//				memberInfo.setIdentity(resultSet.getInt("identity"));
//				memberInfo.setIsSilence(resultSet.getInt("isSilence"));
//				memberInfo.setGroupId(resultSet.getLong("groupId"));
//				memberInfo.setMemberId(resultSet.getLong("memberId"));
//				memberInfo.setNickName(resultSet.getString("nickName"));
//				memberInfo.setMemberHead(resultSet.getString("memberHead"));
//				memberInfo.setMemberName(resultSet.getString("memberName"));
//				memberInfo.setMemberHonor(resultSet.getString("memberHonor"));
//				memberInfos.add(memberInfo);
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return memberInfos;
//	}
//
//	/**
//	 * 指定数量查询群成员
//	 * 
//	 * @param groupId
//	 * @param pageIndex
//	 * @param pageCount
//	 * @return
//	 */
//	public static ArrayList<MemberInfo> queryMembers(long groupId, int count) {
//		String where = "groupId=" + groupId;
//		String orderBy = "joinDate desc";
//		ArrayList<MemberInfo> lMemberInfos = new ArrayList<MemberInfo>();
//		try {
//			ResultSet resultSet = DBManager.querySql(0, MEMBER_TABLE, null, where, orderBy, null, null);
//			int index = 0;
//			while (resultSet.next()) {
//				if (index == count) {
//					break;
//				}
//				int isMember = resultSet.getInt("isMember");
//				if (isMember != 1) {
//					continue;
//				}
//				MemberInfo memberInfo =new MemberInfo();
//				memberInfo.setIdentity(resultSet.getInt("identity"));
//				memberInfo.setIsSilence(resultSet.getInt("isSilence"));
//				memberInfo.setGroupId(resultSet.getLong("groupId"));
//				memberInfo.setMemberId(resultSet.getLong("memberId"));
//				memberInfo.setNickName(resultSet.getString("nickName"));
//				memberInfo.setMemberHead(resultSet.getString("memberHead"));
//				memberInfo.setMemberName(resultSet.getString("memberName"));
//				memberInfo.setMemberHonor(resultSet.getString("memberHonor"));
//				lMemberInfos.add(memberInfo);
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return lMemberInfos;
//	}
//
//	/**
//	 * 查询可交互群成员
//	 * 
//	 * @param groupId
//	 * @param pageIndex
//	 * @param pageCount
//	 * @return
//	 */
//	public static List<MemberInfo> queryValidMembers(long groupId) {
//		List<MemberInfo> lMemberInfos = new ArrayList<MemberInfo>();
//		String where = "groupId=" + groupId;
//		String orderBy = "joinDate desc";
//		String sql = "select * from " + MEMBER_TABLE + " where " + where + " order by " + orderBy;
//		try {
//			ResultSet resultSet = DBManager.querySql(0, sql);
//			while (resultSet.next()) {
//				MemberInfo memberInfo =new MemberInfo();
//				int isMember = resultSet.getInt("isMember");
//				if (isMember != 1) {
//					continue;
//				}
//				memberInfo.setIdentity(resultSet.getInt("identity"));
//				memberInfo.setIsSilence(resultSet.getInt("isSilence"));
//				memberInfo.setGroupId(resultSet.getLong("groupId"));
//				memberInfo.setMemberId(resultSet.getLong("memberId"));
//				memberInfo.setNickName(resultSet.getString("nickName"));
//				memberInfo.setMemberHead(resultSet.getString("memberHead"));
//				memberInfo.setMemberName(resultSet.getString("memberName"));
//				memberInfo.setMemberHonor(resultSet.getString("memberHonor"));
//				lMemberInfos.add(memberInfo);
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		Logger.println(TAG, "queryMemberInfo", lMemberInfos.size());
//		return lMemberInfos;
//	}
//
//	/**
//	 * 查询群主或管理员
//	 * 
//	 * @param groupId
//	 * @param memberId
//	 * 
//	 * @return
//	 */
//	public static List<MemberInfo> queryAdministrator(long groupId) {
//		List<MemberInfo> lMemberInfos = new ArrayList<MemberInfo>();
//		String where = " where groupId=" + groupId;
//		String sql = "select * from " + MEMBER_TABLE + where;
//		try {
//			ResultSet resultSet = DBManager.querySql(0, sql);
//			while (resultSet.next()) {
//				MemberInfo memberInfo =new MemberInfo();
//				int identity = resultSet.getInt("identity");
//				int isSilence = resultSet.getInt("isSilence");
//				int isMember = resultSet.getInt("isMember");
//				if (isMember != 1 || identity == 0) {
//					continue;
//				}
//				memberInfo.setIsSilence(isSilence);
//				memberInfo.setIdentity(resultSet.getInt("identity"));
//				memberInfo.setGroupId(resultSet.getLong("groupId"));
//				memberInfo.setMemberId(resultSet.getLong("memberId"));
//				memberInfo.setNickName(resultSet.getString("nickName"));
//				memberInfo.setMemberHead(resultSet.getString("memberHead"));
//				memberInfo.setMemberName(resultSet.getString("memberName"));
//				memberInfo.setMemberHonor(resultSet.getString("memberHonor"));
//				lMemberInfos.add(memberInfo);
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		Logger.println(TAG, "queryAdministrator", lMemberInfos.size());
//		return lMemberInfos;
//	}
//
//	/**
//	 * 查询用户的所有群
//	 * 
//	 * @param userId
//	 * @param groupType
//	 * @return
//	 */
//	public static List<GroupInfo> queryGroupByUser(long userId, int groupType) {
//		String orderBy = " order by ofg.modifiedDate desc";
//		String where = "where groupType=" + groupType + " and ofg.groupId = ofm1.groupId and ofm1.memberId = " + userId
//				+ " and ofm1.isMember=1";
//		String sql = "SELECT ofg.*,"
//				+ "(SELECT nickName from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as nickName,"
//				+ "(SELECT isSilence from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as isMSilence,"
//				+ "(SELECT identity from ofmember ofm where ofg.groupId=ofm.groupId and ofm.memberId=" + userId
//				+ ") as identity,"
//				+ "(SELECT COUNT(*) from ofmember ofm where ofg.groupId=ofm.groupId and isMember=1) as memberCount"
//				+ " FROM ofgroup ofg,ofmember ofm1 " + where + orderBy;
//		List<GroupInfo> groupInfos=new ArrayList<GroupInfo>();
//		try {
//			ResultSet resultSet = DBManager.querySql(0, sql);
//			while (resultSet.next()) {
//				GroupInfo groupInfo =new GroupInfo();
//				long groupId = resultSet.getLong("groupId");
//				groupInfo.setIsMember(1);
//				groupInfo.setGroupId(groupId);
//				groupInfo.setIdentity(resultSet.getInt("identity"));
//				groupInfo.setIsSilence(resultSet.getInt("isSilence"));
//				groupInfo.setIsMSilence(resultSet.getInt("isMSilence"));
//				groupInfo.setBelongId(resultSet.getLong("belongId"));
//				groupInfo.setAllowedJoin(resultSet.getInt("allowedJoin"));
//				groupInfo.setBelongName(resultSet.getString("belongName"));
//				groupInfo.setGroupType(resultSet.getInt("groupType"));
//				groupInfo.setGroupLevel(resultSet.getInt("groupLevel"));
//				groupInfo.setNickName(resultSet.getString("nickName"));
//				groupInfo.setGroupName(resultSet.getString("groupName"));
//				groupInfo.setGroupLogo(resultSet.getString("groupLogo"));
//				groupInfo.setCreateDate(resultSet.getLong("creationDate"));
//				groupInfo.setModifiedDate(resultSet.getLong("modifiedDate"));
//				groupInfo.setMemberCount(resultSet.getInt("memberCount"));
//				RegionInfo regionInfo = DBForRegion.queryRegionInfo(groupId, 1);
//				if (regionInfo != null) {
//					groupInfo.setRegionInfo(regionInfo);
//				}
//				ArrayList<MemberInfo> lMemberInfos = queryMembers(groupId, 5);
//				groupInfo.setMemberInfos(lMemberInfos);
//				groupInfos.add(groupInfo);
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return groupInfos;
//	}
//
//	/**
//	 * 主动加群
//	 * 
//	 * @return -1插入数据失败，-2该群不允许加入
//	 */
//	static final String ADD_COLUMNS = "groupId,memberId,memberName,nickName,memberHead,"
//			+ "memberHonor,identity,isMember,isSilence,joinWay,remarkInfo,joinDate";
//
//	public static int joinToGroup(RequestInfo requestInfo,boolean create) {
//		Object[] parameters=requestInfo.getParameters();
//		GroupInfo groupInfo=(GroupInfo) parameters[0];
//		String remarkInfo=parameters[1].toString();
//		if (!create) {
//			int allowdJoin = isGroupAllowdJoin(groupInfo.getGroupId());
//			if (allowdJoin == -1) {
//				return -1;
//			}
//			if (allowdJoin == 1) {
//				return -2;
//			}
//		}
//		int isMember = isGroupMember(groupInfo.getGroupId(), requestInfo.getUserId());
//		if (isMember != -2) {
//			String where = "groupId=" + groupInfo.getGroupId() + " and memberId=" + requestInfo.getUserId();
//			String set = "memberName='" + requestInfo.getUserName()+ "'," + "memberHead='" + requestInfo.getUserHead()
//					+ "'," + "nickName='" + requestInfo.getNickName() + "'," + "remarkInfo='"
//					+remarkInfo + "'," + "isMember=" + 0 + "," + "joinDate=" + new Date().getTime();
//			return updateMemberInfo(set, where);
//		} else {
//			String values = groupInfo.getGroupId() + "," + requestInfo.getUserId() + ",'" + requestInfo.getUserName() + "','"
//					+ requestInfo.getNickName() + "','" + requestInfo.getUserHead() + "',''," + (create ? 1 : 0) + ","
//					+ (create ? 1 : 0) + "," + 0 + "," + 0 + ",'" + remarkInfo + "',"
//					+ new Date().getTime();
//			return DBManager.insertSql(0, MEMBER_TABLE, ADD_COLUMNS, values);
//		}
//	}
//	
//	public static int joinToGroup(long userId, MemberInfo memberInfo, boolean create) {
//		if (!create) {
//			int allowdJoin = isGroupAllowdJoin(memberInfo.getGroupId());
//			if (allowdJoin == -1) {
//				return -1;
//			}
//			if (allowdJoin == 1) {
//				return -2;
//			}
//		}
//		int isMember = isGroupMember(memberInfo.getGroupId(), userId);
//		if (isMember != -2) {
//			String where = "groupId=" + memberInfo.getGroupId() + " and memberId=" + userId;
//			String set = "memberName='" + memberInfo.getMemberName()+ "'," + "memberHead='" + memberInfo.getMemberHead()
//					+ "'," + "nickName='" + memberInfo.getMemberNick() + "'," + "remarkInfo='"
//					+ memberInfo.getRemarkInfo() + "'," + "isMember=" + 0 + "," + "joinDate=" + new Date().getTime();
//			return updateMemberInfo(set, where);
//		} else {
//			String values = memberInfo.getGroupId() + "," + userId + ",'" + memberInfo.getMemberName() + "','"
//					+ memberInfo.getMemberNick() + "','" + memberInfo.getMemberHead() + "',''," + (create ? 1 : 0) + ","
//					+ (create ? 1 : 0) + "," + 0 + "," + 0 + ",'" + memberInfo.getRemarkInfo() + "',"
//					+ new Date().getTime();
//			return DBManager.insertSql(0, MEMBER_TABLE, ADD_COLUMNS, values);
//		}
//	}
//
//	/**
//	 * 是否允许加群
//	 * 
//	 * @param groupId
//	 * @return
//	 */
//	private static int isGroupAllowdJoin(long groupId) {
//		String sql = "select allowedJoin from " + GROUP_TABLE + " where groupId=" + groupId;
//		try {
//			ResultSet resultSet = DBManager.querySql(0, sql);
//			if (resultSet.first()) {
//				return resultSet.getInt("allowedJoin");
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return -1;
//	}
//
//	/**
//	 * 被邀请进群
//	 * 
//	 * @return
//	 */
//	public static int inviteToGroup(long groupId, MemberInfo memberInfo) {
//		int isMember = isGroupMember(groupId, memberInfo.getMemberId());
//		if (isMember != -2) {
//			String where = "groupId=" + groupId + " and memberId=" + memberInfo.getMemberId();
//			String set = "memberName='" + memberInfo.getMemberName() + "'," + "memberHead='"
//					+ memberInfo.getMemberHead() + "'," + "nickName='" + memberInfo.getMemberNick() + "',"
//					+ "remarkInfo='" + memberInfo.getRemarkInfo() + "'," + "isMember=" + 0 + "," + "joinDate="
//					+ new Date().getTime();
//			return updateMemberInfo(set, where);
//		} else {
//			String values = groupId + "," + memberInfo.getMemberId() + ",'" + memberInfo.getMemberName() + "','"
//					+ memberInfo.getMemberName() + "','" + memberInfo.getMemberHead() + "','"
//					+ memberInfo.getMemberHonor() + "'," + memberInfo.getIdentity() + "," + 0 + "," + 1 + "," + 1 + ",'"
//					+ memberInfo.getRemarkInfo() + "'," + new Date().getTime();
//			return DBManager.insertSql(0, MEMBER_TABLE, ADD_COLUMNS, values);
//		}
//	}
//
//	/**
//	 * 删除群
//	 * 
//	 * @param where
//	 * @return
//	 */
//	public static int deleteGroup(String where) {
//		int result = DBManager.deleteSql(0, GROUP_TABLE, where);
//		return result;
//	}
//
//	/**
//	 * 删除群成员
//	 * 
//	 * @param where
//	 * @return
//	 */
//	public static int kickoutMember(long groupId, long memberId) {
//		String where = "groupId=" + groupId + " and memberId=" + memberId;
//		int result = DBManager.deleteSql(0, MEMBER_TABLE, where);
//		return result;
//	}
//
//	/**
//	 * 更新群信息
//	 * 
//	 * @param set
//	 * @param where
//	 * @return
//	 */
//	public static int updateGroupLogo(long groupId, String groupLogo) {
//		String set = "groupLogo='" + groupLogo + "'";
//		String where = "groupId=" + groupId;
//		int result = DBManager.updateSql(0, GROUP_TABLE, set, where);
//		if (result == 0) {
//			String set1 = "chatToHead='" + groupLogo + "'";
//			String where1 = "chatToId=" + groupId;
//			DBManager.updateSql(0, MESSAGE_TABLE, set1, where1);
//		}
//		return result;
//	}
//
//	/**
//	 * 更新群信息
//	 * 
//	 * @param set
//	 * @param where
//	 * @return
//	 */
//	public static int updateGroupInfo(String set, String where) {
//		return DBManager.updateSql(0, GROUP_TABLE, set, where);
//	}
//
//	/**
//	 * 更新群成员信息（群昵称、群身份，是否禁言，进群审核）
//	 * 
//	 * @param set
//	 * @param where
//	 * @return
//	 */
//	public static int updateMemberInfo(String set, String where) {
//		return DBManager.updateSql(0, MEMBER_TABLE, set, where);
//	}
//
//	/**
//	 * 判断是否群成员
//	 * 
//	 * @param groupId
//	 * @param memberId
//	 * @return (0待审核、1同意、-1拒绝、2忽略、-2不存在数据)
//	 */
//	public static int isGroupMember(long groupId, long memberId) {
//		String where = "groupId=" + groupId + " and memberId=" + memberId;
//		try {
//			ResultSet resultSet = DBManager.querySql(0, MEMBER_TABLE, null, where, null, null, null);
//			if (resultSet.first()) {
//				return resultSet.getInt("isMember");
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return -2;
//	}
//
//}
